import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BizContractVo } from '@/api/operation/contract/types';

/**
 * 查询列表
 * @param query
 * @returns {*}
 */

export const listContract = (query?: PageQuery): AxiosPromise<BizContractVo[]> => {
  return request({
    url: '/biz-vendor/contract/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询详细
 * @param id
 */
export const getContract = (id: string | number): AxiosPromise<BizContractVo> => {
  return request({
    url: '/biz-vendor/contract/' + id,
    method: 'get'
  });
};

/**
 * 新增
 * @param data
 */
export const addContract = (data: BizContractVo) => {
  return request({
    url: '/biz-vendor/contract',
    method: 'post',
    data: data
  });
};

/**
 * 修改
 * @param data
 */
export const updateContract = (data: BizContractVo) => {
  return request({
    url: '/biz-vendor/contract',
    method: 'put',
    data: data
  });
};

/**
 * 删除
 * @param id
 */
export const delContract = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-vendor/contract/' + id,
    method: 'delete'
  });
};


/**
 * 作废
 * @param data
 */
export const invalidateContract = (id: string | number) => {
  return request({
    url: '/biz-vendor/contract/invalidate/' + id,
    method: 'put',
  });
};


/**
 * 生效
 * @param data
 */
export const effectiveContract = (id: string | number) => {
  return request({
    url: '/biz-vendor/contract/effective/' + id,
    method: 'put',
  });
};

/**
 * 获取酒店生效合同
 * @param data
 */
export const getVendorContract = (vendorId: string | number): AxiosPromise<BizContractVo> => {
  return request({
    url: '/biz-vendor/contract/vendor/' + vendorId,
    method: 'get',
  });
};

/**
 * 删除合同附件 
 * @param id 附件id
 */
export const delContractFile = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-vendor/contract/attachment/' + id,
    method: 'delete'
  });
};

